package writtenexamination.boss;

import java.util.HashMap;

/**
 * @author cyt
 * @create 2020-10-15 下午 7:30
 */
public class Ta {
    public static void main(String[] args) {
        Ta ta = new Ta();
        String[] ip = {"192.168.1.1", "192.168.1.2", "192.168.1.3"};
        String[] black = {"192.168.1.3", "192.168.1.4"};
        boolean[] blackIp = ta.isBlackIp(ip, black);
        for (int i = 0; i < blackIp.length; i++) {
            System.out.println(blackIp[i]);
        }
    }

    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * @param ipArr      string字符串一维数组 待校验 IP 列表
     * @param blackIpArr string字符串一维数组 IP 黑名单列表
     * @return bool布尔型一维数组
     */
    public boolean[] isBlackIp(String[] ipArr, String[] blackIpArr) {
        // write code here
        int blackLen = blackIpArr.length;
        int ipLen = ipArr.length;
        HashMap<String, String> map = new HashMap<>();
        boolean[] ans = new boolean[ipArr.length];
        for (int i = 0; i < blackIpArr.length; i++) {
            map.put(blackIpArr[i], blackIpArr[i]);
        }
        for (int i = 0; i < ipArr.length; i++) {
            boolean b = map.containsKey(ipArr[i]);
            ans[i] = b;
        }
        return ans;
    }
}
